package filter;

import validation.Validation;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by v on 17-5-7.
 */
@WebFilter(filterName = "HomeFilter",value = "/home.html")
public class HomeFilter implements Filter{
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request=(HttpServletRequest) servletRequest;
        HttpServletResponse response=(HttpServletResponse) servletResponse;

        if(Validation.LoginValidation(request,response)){
            filterChain.doFilter(servletRequest,servletResponse);
        }else {
            response.sendRedirect("/index.html");
        }
    }
}
